Repository navigation
fix(bgp): let Metro's drawables win over an embedded library's copy - #521
Merged
Merged
Conversation
Some libraries commit the drawables Metro generates for their JS assets to their own res, and the app's bundle writes the same files to generated/res/react. Both ended up as generated res of the brownfield module, so packaging failed with duplicate resources. Treat Metro's output as the module's own in the resource copy task, which also orders the copy after the bundle and keys its cache on it.
KisaneNeko
marked this pull request as ready for review
November 5, 2026 17:44
andrei-zgirvaci
approved these changes
Nov 6, 2026
andrei-zgirvaci
left a comment
Collaborator
There was a problem hiding this comment.
LGTM! This fixes our blocker. Thank you!
hurali97
approved these changes
Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Some libraries commit the drawables Metro generates for their JS assets (
node_modules_<lib>_assets_*) to their ownres/. The app's bundle writes the same files togenerated/res/react, and both end up as generated res of the brownfield module, so packaging fails withDuplicate resources. Nothing orderedcopyExplodedResFor<Variant>after the bundle task either, and its cache key didn't include Metro's output.Change
ResourceTaskProcessor.kt:CopyExplodedResTaskreads thecreateBundle<Variant>JsAndAssetstask'sresourcesDiras one of the module's own res dirs, so the merger from fix(bgp): merge res/values of embedded libraries instead of overwriting #513 drops a library's copy and Metro's wins. Reading the task's output also orders the copy after the bundle and adds Metro's files to the cache key, so@CacheableTaskstays.VariantHelper.getMetroBundleTaskNameandutils/TaskOutputs.kt: the bundle task name and the task-output lookup moved out ofRNSourceSets.kt, which now uses the same helpers.Reproduced with RNApp by copying one of its Metro drawables into an embedded library's
res/:mainfails inpackageDevDebugResourceswith the duplicate, this branch builds and the AAR has one copy per density, byte-identical to Metro's.Before merging
Build the host app against an AAR with a colliding drawable and check the image renders.